namespace Domotica.Windows.Controls
{
    using System;
    using System.Collections;
    using System.Runtime.CompilerServices;

    internal class SingleChildEnumerator : IEnumerator
    {
        private object _child;
        private int _count;
        private int _index = -1;

        internal SingleChildEnumerator(object Child)
        {
            this._child = RuntimeHelpers.GetObjectValue(Child);
            this._count =Child == null ? 0 : 1;
        }

        public bool MoveNext()
        {
            this._index++;
            return (this._index < this._count);
        }

        public void Reset()
        {
            this._index = -1;
        }

        public object Current
        {
            get
            {
                if (this._index != 0)
                {
                    return null;
                }
                return this._child;
            }
        }
    }
}

